package sg.edu.nus.iss.vmcs.maintenance;

/*
 * Copyright 2003 ISS.
 * The contents contained in this document may not be reproduced in any
 * form or by any means, without the written permission of ISS, other
 * than for the purpose for which it has been supplied.
 *
 */

import java.awt.event.*;
import java.awt.*;

import sg.edu.nus.iss.vmcs.util.MessageDialog;
import sg.edu.nus.iss.vmcs.util.Undoable;

/**
 *
 *
 * @version 3.0 5/07/2003
 * @author Olivo Miotto, Pang Ping Li
 */

public class UndoListener implements ActionListener {

	private MaintenanceController mctrl;

	public UndoListener(MaintenanceController mc) {
		mctrl = mc;
	}
	public void actionPerformed(ActionEvent e) {

		Undoable cmd=mctrl.getCommandHistory().popCommand();
		if(cmd!=null){
			cmd.undo();
			System.out.println("Undo finished.");
		}			
		else{
			System.out.println("No operation to undo.");
			MessageDialog msg=new MessageDialog(null,"No operation to undo.");
			msg.setLocation(500, 500);
		}
			
	}

}